/**
 * Created by CDog on 15/8/19.
 */
wcApp.filter('weekday', [function () {
    return function (input, offset) {
        if (input) {
            var d = new Date();
            d.setFullYear(parseInt(input.substr(0, 4)));
            d.setMonth(parseInt(input.substr(4, 2)) - 1);
            d.setDate(parseInt(input.substr(6, 2)) + offset);
            return d.getDay() + 1;
        }
    };
}])
    .filter('weekdayShow', [function () {
        return function (input, flag) {
            if (input) {
                var words = ["", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
                return flag ? words[input].substr(0, 3) : words[input];
            }
        };
    }])
    .filter('descShow', [function () {
        return function (input) {
            if (input) {
                var cur = 0;
                if (!input[cur]) {
                    cur++;
                }
                var words = {
                    "00": "晴",
                    "01": "多云",
                    "02": "阴",
                    "03": "阵雨",
                    "04": "雷阵雨",
                    "05": "雷阵雨伴有冰雹",
                    "06": "雨夹雪",
                    "07": "小雨",
                    "08": "中雨",
                    "09": "大雨",
                    "10": "暴雨",
                    "11": "大暴雨",
                    "12": "特大暴雨",
                    "13": "阵雪",
                    "14": "小雪",
                    "15": "中雪",
                    "16": "大雪",
                    "17": "暴雪",
                    "18": "雾",
                    "19": "冻雨",
                    "20": "沙尘暴",
                    "21": "小到中雨",
                    "22": "中到大雨",
                    "23": "大到暴雨",
                    "24": "暴雨到大暴雨",
                    "25": "大暴雨到特大暴雨",
                    "26": "小到中雪",
                    "27": "中到大雪",
                    "28": "大到暴雪",
                    "29": "浮尘",
                    "30": "扬沙",
                    "31": "强沙尘暴",
                    "53": "霾",
                    "99": "未知"

                };
                return words[input[cur]];
            }
        };
    }])
    .filter('windTypeShow', [function () {
        return function (input) {
            if (input) {
                var cur = 0;
                if (!input[cur]) {
                    cur++;
                }
                var words = [
                    "无持续风向",
                    "东北风",
                    "东风",
                    "东南风",
                    "南风",
                    "西南风",
                    "西风",
                    "西北风",
                    "北风",
                    "旋转风"
                ];
                return words[input[cur]];
            }
        };
    }])
    .filter('windStrengthShow', [function () {
        return function (input) {
            if (input) {
                var cur = 0;
                if (!input[cur]) {
                    cur++;
                }
                var words = [
                    "微风",
                    "3-4级",
                    "4-5级",
                    "5-6级",
                    "6-7级",
                    "7-8级",
                    "8-9级",
                    "9-10级",
                    "10-11级",
                    "11-12级"
                ];
                return words[input[cur]];
            }
        };
    }])
    .filter('dateShow', [function () {
        return function (input) {
            if (input) {
                return input.substr(0, 4) + "年" + parseInt(input.substr(4, 2)) + "月" + parseInt(input.substr(6, 2)) + "日" + input.substr(8, 2) + ":" + input.substr(10, 2);
            }
        };
    }])
    .filter('descIcon', [function () {
        return function (input) {
            if (input) {
                var cur = 0;
                if (!input[cur]) {
                    cur++;
                }
                var words = {
                    "00": "ion-ios-sunny-outline",
                    "01": "ion-ios-partlysunny-outline",
                    "02": "ion-ios-cloudy-outline",
                    "03": "ion-ios-rainy-outline",
                    "04": "ion-ios-cloudy-outline",
                    "05": "ion-ios-snowy",
                    "06": "ion-ios-snowy",
                    "07": "ion-ios-rainy-outline",
                    "08": "ion-ios-rainy-outline",
                    "09": "ion-ios-rainy-outline",
                    "10": "ion-ios-rainy-outline",
                    "11": "ion-ios-rainy-outline",
                    "12": "ion-ios-rainy-outline",
                    "13": "ion-ios-snowy",
                    "14": "ion-ios-snowy",
                    "15": "ion-ios-snowy",
                    "16": "ion-ios-snowy",
                    "17": "ion-ios-snowy",
                    "18": "ion-ios-cloudy-outline",
                    "19": "ion-ios-rainy-outline",
                    "20": "ion-ios-flame-outline",
                    "21": "ion-ios-rainy-outline",
                    "22": "ion-ios-rainy-outline",
                    "23": "ion-ios-rainy-outline",
                    "24": "ion-ios-rainy-outline",
                    "25": "ion-ios-rainy-outline",
                    "26": "ion-ios-snowy",
                    "27": "ion-ios-snowy",
                    "28": "ion-ios-snowy",
                    "29": "ion-ios-flame-outline",
                    "30": "ion-ios-flame-outline",
                    "31": "ion-ios-flame-outline",
                    "53": "ion-ios-flame-outline",
                    "99": "ion-ios-flame-outline"

                };
                return words[input[cur]];
            }
        };
    }]);